﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ObviousCode.Aspect.PluginLibrary.Interfaces;
using ObviousCode.Common.Utils.Library.Dictionaries.Persistance;
using ObviousCode.UI.Aspect.Persistence.AspectSurface.Savers;
using ObviousCode.UI.Aspect.Events;

namespace ObviousCode.UI.Aspect.Persistence.AspectSurface.Loaders
{
    public abstract class SurfaceLoader : Loader<IAspectSurface>
    {
        protected abstract override void PerformLoad(IAspectSurface parent, ObviousCode.Common.Utils.Library.Dictionaries.PropertyDictionary saveData);

        public abstract override int Version { get; }

        public static SurfaceLoader LatestVersion
        {
            get
            {
                return new SurfaceLoader_V1();
            }
        }

        public override string Tag
        {
            get { return SurfaceSaver.ObjectTag; }
        }

        protected AspectItemRequestedEventArgs FireItemRequestedEvent(string id)
        {
            if (ItemRequested != null)
            {
                AspectItemRequestedEventArgs e = new AspectItemRequestedEventArgs(id);
                
                ItemRequested(this, e);

                return e;
            }

            return new AspectItemRequestedEventArgs(id);
        }

        public event EventHandler<AspectItemRequestedEventArgs> ItemRequested;
    }
}
